//引入request方法
const {
  request
} = require('./request')


//统一管理不同的业务接口api

module.exports = {
  // 获取资产信息
  getcc: () => {
    let token = wx.getStorageSync('token')

    return request('fzf/user/amount', 'GET', {
      token: token
    }, true)
  },
  //调取轮播图接口
  getBanner: () => {
    return request('fzf/banner/list', 'GET', {
      type: 'index'
    }, true)
  },
  //调取商品分类接口
  getGoodsCate: () => {
    return request('fzf/shop/goods/category/all', 'GET', {}, true)
  },
  fzf_categories: (pageSize1) => {
    return request('fzf/shop/goods/list', 'GET', {
      pageSize: pageSize1
    }, true)
  },

  // 拼团
  pintuan: () => {
    return request('fzf/shop/goods/list', 'POST', {
      pingtuan: true
    }, true)
  },
  //九宫格
  homeJGG: () => {
    return request("fzf/shop/goods/category/all", 'GET', {}, true)
  },
  // 优惠资讯
  xjh_YHZU: () => {
    return request('fzf/notice/list', 'GET', {}, true)
  },
  xjh_XSMS: () => {
    return request("fzf/shop/goods/list", 'GET', {
      miaosha: true
    }, true)
  },
  //商品详情
  categories: (id) => {
    return request('fzf/shop/goods/detail', 'GET', {
      id
    }, true)
  },
  // 爆品
  fzf_baopin: () => {
    return request("fzf/shop/goods/list", 'GET', {
      recommendStatus: 1
    }, true)
  },
  //砍价接口
  fzf_kanjia: () => {
    return request("fzf/shop/goods/list", 'GET', {
      kanjia: true
    }, true)
  },
  //添加商品收藏接口
  addGoodsFav: (goodsId) => {
    return request('fzf/shop/goods/fav/add', 'POST', {
      goodsId
    }, true)
  },
  // 帮助中心接口
  addbzzx: (goodsId) => {
    return request('fzf/cms/category/list', 'GET', {}, true)
  },
  // 帮助中心里面每一项
  addbid: (Id) => {
    return request('fzf/cms/news/detail', 'GET', {
      id: Id
    }, true)
  },
  addbzzxa: (goodsId) => {
    return request('fzf/cms/news/list', 'POST', {
      categoryId: goodsId
    }, true)
  },
  getClassifyPajamas: () => {
    return request('fzf/shop/goods/category/all', 'POST', {}, true)
  },
  getGoods: (categoryId) => {
    // console.log(categoryId);
    return request('fzf/shop/goods/list', 'POST', {
      categoryId
    }, true)

  },
  getList: () => {
    return request('fzf/shop/goods/list', 'POST', {}, true)

  },

  // 订单列表
  getGoodss: () => {
    return request('fzf/order/list', 'POST', {}, true)

  },
  //优惠券列表
  coupons: function coupons(data) {
    return request('tz/discounts/coupons', true, 'get', data);
  },
  //领取优惠券
  getCoupons: (token) => {

    return request('tz/discounts/fetch', true, 'post', true);
  },
  //我的优惠劵
  myCoupons: function coupons(data) {
    let token = wx.getStorageSync('token')
    return request('tz/discounts/my', true, 'get', {
      token: token
    });
  },

  //登录/注册
  authorize: (code) => {
    console.log(code);
    return request('fzf/user/wxapp/authorize', 'POST', {
      code
    }, true)
  },
  //修改用户信息
  modifyUser: (obj) => {
    console.log(obj)
    return request('fzf/user/modify', 'POST', obj, true)
  },
  //获取用户详情的信息
  getUserDetail: (token) => {
    return request('fzf/user/detail', 'GET', {
      token
    }, true)
  },
  //检测token
  checkToken: function checkToken(token) {
    return request('/user/check-token', true, 'get', {
      token: token
    });
  },
  startBanner: () => {
    return request('fzf/banner/list', 'GET', {
      type: 'app'
    }, true)
  },


  //兑换优惠券
  mr_duihuan_coupon: () => {
    let token = wx.getStorageSync('token')
    return request('tz/discounts/exchange', 'POST', {
      token: token,
      number: 'number',
      pwd: 'pwd'
    }, true)


    // 帮助中心每一项里面的接口

    //取消商品收藏

    //.....



  },
  //加入购物车接口
  xjh_JRGUC: (goodsId, number) => {
    let token = wx.getStorageSync('token')
    return request("fzf/shopping-cart/add", 'POST', {
      goodsId,
      number,
      selected: false,
      token,
    }, true)
  },
  // 商品数量
  fzf_gwcsl: (key, number) => {
    let token = wx.getStorageSync('token')
    return request("fzf/shopping-cart/modifyNumber", 'POST', {
      key,
      number,
      token,
    }, true)
  },
  // 商品删除
  fzf_gwcsc: (key) => {
    let token = wx.getStorageSync('token')
    return request("fzf/shopping-cart/remove", 'POST', {
      key,
      token,
    }, true)
  },
  //购物车商品
  fzf_gwcsp: () => {
    let token = wx.getStorageSync('token')
    return request("fzf/shopping-cart/info", 'GET', {
      token,
    }, true)
  },
  // 修改购物车状态
  fzf_gwcxzong: (key, selected) => {
    let token = wx.getStorageSync('token')
    return request("fzf/shopping-cart/select", 'POST', {
      key,
      selected,
      token,
    }, true)
  },
  fzf_shouc: (goodsId,type) => {
    let token = wx.getStorageSync('token')
    return request("fzf/shop/goods/fav/add", 'POST', {
      goodsId,
      type,
      token,
    }, true)
  },




}